package com.znh.entity;

import com.znh.enums.PieceActionEnum;
import com.znh.enums.PieceInitLocationEnum;
import com.znh.enums.PiecePlayerEnum;

import java.awt.*;

/**
 * @version 1.0
 * @Author znh
 * @Date 2024/5/24 下午3:24
 * @注释 士类
 */
public class Shi extends Piece {
    public Shi(int id,Point point, PiecePlayerEnum player, PieceInitLocationEnum initLocation) {
        super(id,"shi", point, player, initLocation, new StringBuilder().append("images/shi")
                .append(player == PiecePlayerEnum.RED ? "0" : "1").append(".png").toString());
    }

    @Override
    public boolean isMove(Point tp) {
        PieceActionEnum action = action(tp);
        //是否在九宫内、是否正斜线移动、是否移动一步
        return isJiuGong(tp) && action == PieceActionEnum.FORWARDSLASH && getStep(tp, PieceActionEnum.FORWARDSLASH) == 1;
    }

    @Override
    public boolean simulateMove(Point tp) {
        return isMove(tp) && super.simulateMove(tp);
    }
}
